<? 
require_once("admin/classes/check_customer_session.php");
check_customer_session(); 
?>
<?php require_once('include/header.php'); ?>
<?
if($_GET['action'] == "CHANGE")
{
	$query_data = "Update scrap set approve ='Y' where scrap_id=".$_REQUEST['sid'];
	$result_update	= mysql_query ( $query_data ) or die(mysql_error());
}

if($_GET['action'] == "CANCEL")
{
	$query_data = "Delete from scrap where scrap_id=".$_REQUEST['sid'];
	$result_update	= mysql_query ( $query_data ) or die(mysql_error());
}

if(!isset($_REQUEST['dir'])){
	$dir = "DESC";
} else {
	$dir = $_REQUEST['dir'];
}
?>
<? if ($_REQUEST['b'] == ""){ $b=0; } else { $b = $_REQUEST['b'];} ?>

      <div id="middle_container_for_innerpage">
      <div id="innerpage_top_image"><img src="images/images/innerpage_top_corner_820x5.jpg"  height="5" /></div> 
      <div id="middle_inner_container">
      <div id="left_menu_column">
            <div id="menu_heading">Quick Search</div>
            <div id="left_menu_link">
            	<a href="#" class="left_menu">Quick Search</a><br />
                <a href="#" class="left_menu">Quick Search</a><br />
                <a href="#" class="left_menu">Quick Search</a><br />
                <a href="#" class="left_menu">Quick Search</a><br />
                <a href="#" class="left_menu">Quick Search</a><br />
                <a href="#" class="left_menu_border_bottom">Quick Search</a>
                <div id="menu_heading2">Quick Search</div>
            </div>
            
        </div>
        
        <?php require_once('include/left_menu.php'); ?>
<div id="middle_inner_container">
      <div id="left_menu_column">
            <div id="menu_heading">Quick Search</div>
            <div id="left_menu_link">
            	<a href="#" class="left_menu">Quick Search</a><br />
                <a href="#" class="left_menu">Quick Search</a><br />
                <a href="#" class="left_menu">Quick Search</a><br />
                <a href="#" class="left_menu">Quick Search</a><br />
                <a href="#" class="left_menu">Quick Search</a><br />
                <a href="#" class="left_menu_border_bottom">Quick Search</a>
                <div id="menu_heading2">Quick Search</div>
            </div>
        </div>
        
        <div id="inner_page_middle_data">
        <div id="page_heading">Delete Your messages or Approve</div>
		  <p>
		  <?
		
		$sql = "SELECT customer.customer_id, customer.name, customer.surname, message.message, message.message_id, customer.image_1 FROM message INNER JOIN customer ON message.from = customer.customer_id WHERE message.approve ='Y' and message.to =".$_SESSION['ep_customer_id'];
//	$sql.= "and customer.status = 'Y'";

		$rs = mysql_query($sql) or die(mysql_error());
		$cnt = mysql_num_rows($rs);
		$sql .= " LIMIT $b, $pagecount_1";
		$rs = mysql_query($sql) or die(mysql_error());


		?>
		  <!--		display dynamic data -->
              <?
	if(@mysql_num_rows($rs)>0){
				?>
              Total number of messages <?php echo $b; ?> to <?php echo $cnt+ $b; ?> out of <?php echo $cnt; ?> </p>
              <?	while($row=mysql_fetch_array($rs)){ ?>        
              <div id="approv_message_container">
              	<div id="approv_message_from_heading">From</div>
                <div id="approv_message_message_heading">messages</div>
                <div id="approv_message_app-del_heading">Approve or Delete</div>
              </div>
          	  <div id="approv_message_container">
          		<div id="approv_message_from_content">
				<?php echo $row['name']; ?> <?php echo $row['surname']; ?><br>
                <?if($row['image_1']){?>
                <a href="profile.php?cid=<?php echo $row['customer_id']; ?>"><img src="uploaded/<?=$row['image_1']?>" width="80" height="80" border="0" class="image-border1"></a>
                <?}else{?>
                <a href="profile.php?cid=<?php echo $row['customer_id']; ?>"><?if($row['gender']="Male"){?><img src="images/images/default_eparinay_groom.jpg" width="90" height="90" border="0" class="image_border" ><?} else{?>
				<img src="images/images/default_eparinay_bride.jpg" width="90" height="90" border="0" class="image_border" ><?}?></a>
                <?}?>            </div>
            <div id="approv_message_message_content"><?php echo $row['message']; ?></div>
            <div id="approv_message_app-del_content">
            	<a href="JavaScript:if(confirm('Do you want to Approve this message?')){self.location.href='see_messages.php?sid=<?php echo $row['message_id']; ?>&action=CHANGE';}" class="AstroGoLink">Approve</a>&nbsp;| 
                <a href="JavaScript:if(confirm('Do you want to Delete this message?')){self.location.href='see_messages.php?sid=<?php echo $row['message_id']; ?>&action=CANCEL';}" class="AstroGoLink">Delete</a>
          </div>
</div><?}

	} else {?>
          <div id="break_only"><p style="text-align:center;">Sorry !! No results found.</p></div>
            <?}?>
            <!--pagecount table starts here-->
            <? if ($cnt > $pagecount_1) {?>
            <div id="page_count"><?
						$qrystr="&sortBy=$sortBy&dir=$dir&con=".$conn;
						displayPageNo($b,$cnt,$qrystr,"link-pagination",$pagecount_1);
					?>
            </div>
            <? } ?>

        </div>
        </div>
        

       
       
      </div> 
      <div id="corner_container_bottom_for_innerpage"><img src="images/images/innerpage_bottom_corner_820x10.jpg"  height="10" /></div>
    </div> 
      <!-- middle_container ends -->
    
    
        
    
<?php require_once('include/footer.php'); ?>
